package net.hn.hnms.biz.project.controller;

import cn.dev33.satoken.annotation.SaCheckPermission;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import net.hn.hnms.biz.project.request.PlanInvestmentReq;
import net.hn.hnms.biz.project.service.PlanInvestmentService;
import net.hn.hnms.biz.project.vo.PlanInvestmentVo;
import net.hn.hnms.sys.common.core.domain.R;
import net.hn.hnms.sys.common.core.domain.ResponsePage;
import net.hn.hnms.sys.common.core.web.controller.BaseController;
import net.hn.hnms.sys.common.log.annotation.Log;
import net.hn.hnms.sys.common.log.enums.BusinessType;
import net.hn.hnms.sys.common.mybatis.core.page.PageQuery;
import net.hn.hnms.sys.common.satoken.config.AutoSetMineCode;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Api(value = "投资费用计划", tags = {"投资费用计划信息"})
@RestController
@RequestMapping("/project/investment")
public class PlanInvestmentController extends BaseController  {


    @Autowired
    private PlanInvestmentService planInvestmentService;

    @ApiOperation("新增投资费用计划")
    @SaCheckPermission("project:investment:add")
    @PostMapping("/add")
    @Log(title = "新增投资费用计划", businessType = BusinessType.INSERT)
    public R<Void> add(@Validated @RequestBody PlanInvestmentReq planWashing) {
        return toAjax(planInvestmentService.insert(planWashing));
    }



    @ApiOperation("删除投资费用计划")
    @SaCheckPermission("project:investment:delete")
    @ApiImplicitParam(name = "idList", value = "要删除的id值,用逗号间隔", required = true, allowMultiple = true, dataType = "String", paramType = "query")
    @DeleteMapping("delete")
    @Log(title = "删除投资费用计划", businessType = BusinessType.DELETE)
    public R<Void> delete(@RequestParam("idList") List<String> idList) {
        planInvestmentService.deleteBatch(idList);
        return R.ok();
    }


    @ApiOperation("修改投资费用计划")
    @SaCheckPermission("project:investment:update")
    @PutMapping("/update")
    @Log(title = "修改投资费用计划", businessType = BusinessType.UPDATE)
    public R<Void> update(@Validated @RequestBody PlanInvestmentReq planWashing) {
        planInvestmentService.updateById(planWashing);
        return R.ok();
    }




    @ApiOperation("启用/禁用")
    @SaCheckPermission("project:investment:status:change")
    @PutMapping("/status/change/{id}/{status}")
    public R<Void> changeStatus(@PathVariable("id") String id, @PathVariable("status") Integer status) {
        planInvestmentService.changeStatus(id, status);
        return R.ok();
    }


    @ApiOperation("获取投资费用分页列表")
//    @SaCheckPermission("plan:washing:page")
    @GetMapping("/page")
    @AutoSetMineCode
    public R<ResponsePage<PlanInvestmentVo>> page(PlanInvestmentReq planWashing, PageQuery pageQuery) {
        return R.ok(planInvestmentService.selectPageList(planWashing, pageQuery));
    }



    @ApiOperation("获取投资费用计划列表")
//    @SaCheckPermission("plan:washing:list")
    @GetMapping("/list")
    public R<List<PlanInvestmentVo>> list(PlanInvestmentReq planWashing) {
        return R.ok(planInvestmentService.selectList(planWashing));
    }






}
